package com.keya.features.operations;

import com.keya.base.sh.RunShell;
import com.keya.base.sh.RunShellRet;
import io.micrometer.core.instrument.Metrics;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.ibatis.annotations.Case;

@Data
@AllArgsConstructor
public class MoveScuOp {

    private String host;

    private String port;

    private String dst;

    // self
    private String aet;

    // peer
    private String aec;

    // self port
    private String selfPort;

    private String StudyInstanceUID;

    private String SeriesInstanceUID;

    private String desc;

    private Integer timeout;

    Case c;

    public RunShellRet run() throws Exception {
        return Metrics.timer("op_movescu").recordCallable(this::runShellRet);
    }

    public RunShellRet runShellRet() throws Exception {
        String[] cmds = {"movescu", "-aec", aec, "-aem", aet,
                "-aet", aet, "--port", selfPort,
                "-k", "QueryRetrieveLevel=SERIES",
                "-k", String.format("StudyInstanceUID=%s", StudyInstanceUID),
                "-k", String.format("SeriesInstanceUID=%s", SeriesInstanceUID),
                "-od", dst, host, port};
        return RunShell.runShell(desc, cmds, timeout);
    }
}
